import React from 'react'

import Constants from '../../common/Constants'
import BaseAction from '../common/BaseAction'

export default class HeartLoveRquestSelfDataAction extends BaseAction {
  constructor(props) {
    super(props)

    this.moduleType = Constants.MODULE_TYPE.HEART
    this.name = 'HeartLoveRquestSelfDataAction'
  }

  _dealCall(caller, data) {
    caller.setState({
      viewStatus: 2
    })
  }

  finish(data, isSucceed, response) {
    console.log('HeartLoveRquestSelfDataAction-', data, isSucceed, response)
    if (isSucceed) {
      data.beenUpdated = false
      this.caller.setState({
        viewStatus: 3,
        loveData: data,
        isResponeUpdate: true,
        loadComplete: true
      })
      this.caller.getMedia()
    } else if (response) {
      // if (response.status === 401) {
      //   this._dealUnauthorized(this.caller)
      // } else {
      //   this.caller.setState({ viewStatus: response.status })
      // }
    } else if (data && data.status === 404) {
      // this.caller.setState({
      //   viewStatus: data.status,
      //   loadComplete: true,
      //   loveData: {}
      // })
    } else {
      this.caller.showToUpDateLoveInfo()
      // this.caller.setState({
      //   viewStatus: 0,
      //   loadComplete: true,
      //   loveData: {}
      // });
    }
  }
}
